﻿@{
    Layout = "~/Views/Shared/_Main.cshtml";
}
<style type="text/css">
    textarea
    {
        width: 400px;
        height: 80px;
        border: 1px solid #ccc;
        padding: 2px;
    }
</style>
<link href="../../CSS/PageStyle.css" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript" src="/Res/MyJs.js"></script>
<script type="text/javascript">
    $(function () {
        $.post("/SystemConfiguration/BindDropwown", { keyName: 'SourceType' }, function (result) {
            $("#ddlSourceType").empty();
            $("#ddlSourceType").attr("style", "width:37%");
            if (result.length > 0) {
                for (var i = 0; i < result.length; i++) {
                    if (result[i].Value == '@Model.SourceType') {
                        $("#ddlSourceType").append("<option value='" + result[i].Value + "'  selected = 'selected'>" + result[i].Name + "</option>"); //为Select追加一个Option(下拉项) 
                    } else {
                        $("#ddlSourceType").append("<option value='" + result[i].Value + "'  >" + result[i].Name + "</option>"); //为Select追加一个Option(下拉项) 
                    }
                }
            }
        });

        $("#CallBackType").val('@Model.CallBackType');
        $("#Status").val('@Model.Status');

        var id = $("#GUID").val();
        $.post("/SystemConfiguration/SourceGetConnstr/?id=" + escape(id), function (res) {
            $("#main1").html(res);
        });

        var i = 30;
        $('#addTextImput').click(function () {
            if (i < 100) {
                $('#main1').append("<div id='div" + i + "' style='margin-top:5px'><textarea class=\"AddConnTxt\"  name=\"txt_tex" + i + "\"/><img alt=\"删除\" title=\"点击删除\" onclick=\"deleteItem('" + i + "');\" src=\"/Images/del.gif\" id=\"del_button\"/></div>");
                i++;
            } else {
                alert("最多加100个");
            }

        });
        $('.del-text').live('click', function () {
            $(this).parent().remove();
            i--;
        });
        $('#del-text').live('click', function () {
            $(this).parent().remove();
            i--;
        });
    });

    function deleteItem(parameters) {
        $("#div" + parameters).remove();
    }
    function SubmitForm() {
        $.post("/SystemConfiguration/EtlSourceUpdateConn", { query: jv.GetDivJson($("#main1"), 4) }, function (res) {
            window.location.href = "/SystemConfiguration/EtlSourceList";
        });
        $('#ff').form('submit');
    }
</script>
@Html.ValidationSummary(true)
<form id="ff" action="/SystemConfiguration/UpdateSubmit" method="post">
<div style="margin: 5px;">
    <div id="p" class="easyui-panel" style="width: 600px; padding: 10px 5px 10px 5px;"
        data-options="title:'源系统信息编辑',iconCls:'icon-edit'">
        <table style="width: 98%;" cellpadding="0" cellspacing="0" class="table_bg">
            <colgroup>
                <col style="width: 27%;" />
                <col style="width: 73%;" />
            </colgroup>
            <tr>
                <td style="text-align: right;">
                    系统名称：
                </td>
                <td>
                    <input type="hidden" id="hdd_GUID" name="GUID" value="@Model.GUID" />
                    <input type="text" id="txt_SourceSysName" name="SourceSysName" value="@Model.SourceSysName" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    系统编号：
                </td>
                <td>
                    <input type="text" id="txt_SourceSysCode" name="SourceSysCode" value="@Model.SourceSysCode" disabled="disabled" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    数据库类型：
                </td>
                <td>
                    <select id="ddlSourceType" name="SourceType">
                    </select>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    状态：
                </td>
                <td>
                    <select id="ddlStatus" name="Status">
                        <option value="1">启用</option>
                        <option value="2">禁用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    回调名称：
                </td>
                <td>
                    <input type="text" id="txt_CallBackName" name="CallBackName" value="@Model.CallBackName" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    回调类型：
                </td>
                <td>
                    <select id="ddlCallBackType" name="CallBackType">
                        <option value="1">存储过程</option>
                        <option value="2">WEB服务</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    描述：
                </td>
                <td>
                    <textarea id="txt_SourceSysDescription" rows="5" name="SourceSysDescription">@Model.SourceSysDescription</textarea>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    数据库连接配置：
                </td>
                <td>
                    <input type="button" id="addTextImput" value="增加数据连接配置" />
                    <br />
                    <div id="main1" style="text-align: left; margin-top: 5px; margin-bottom: 5px;">
                        <textarea class="ConnTxt" name="txt_text1" id="txt_text1"></textarea>
                        <div class="editor-label" style="padding-top: 15px;" />
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input id="Save" type="submit" value=" 保存 " onclick="SubmitForm()" />
                    <input type="button" value=" 返回 " onclick="back();" />
                </td>
            </tr>
        </table>
    </div>
</div>
</form>
